package com.alkaid.search.controller;

import com.alkaid.commons.controller.BaseController;
import com.alkaid.commons.param.anime.AnimePlay;
import com.alkaid.commons.utils.JsonResult;
import com.alkaid.search.serice.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Kylin
 */
@RestController
@RequestMapping("/api")
public class DemoController extends BaseController {

    private SearchService searchService;

    @Autowired
    public void setSearchService(SearchService searchService) {
        this.searchService = searchService;
    }

    @GetMapping("/search")
    public JsonResult<List<AnimePlay>> search(String s) {
        List<AnimePlay> animePlays = searchService.searchAnime(s);
        return new JsonResult<>(200, animePlays, "success");
    }
}
